package sdk.weinxin.beans.massmessage;

import sdk.weinxin.beans.message.Card;
import sdk.weinxin.beans.massmessage.preview.Preview;

import sdk.weinxin.beans.massmessage.preview.WxcardPreview;

public class MassWxcardMessage extends MassMessage {

    private Card wxcard;

    public MassWxcardMessage() {
        super();
        this.setMsgType("wxcard");
    }

    public MassWxcardMessage(String cardId) {
        super();
        wxcard = new Card(cardId);
        this.setMsgType("wxcard");
    }

    public Card getWxcard() {
        return wxcard;
    }

    public void setWxcard(Card wxcard) {
        this.wxcard = wxcard;
    }

    @Override
    public Preview convert() {
        Preview preview = new WxcardPreview(wxcard.getCardId());
        if (this.getToUser() != null && this.getToUser().size() > 0) {
            preview.setToUser(this.getToUser().iterator().next());
        }
        return preview;
    }

}
